﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Navigation;
using Microsoft.Phone.Controls;
using Microsoft.Phone.Shell;
using Common.Utilities;
using Common.Library;
using OnlineVideos.UI;
using Microsoft.Phone.Tasks;

namespace Social_Celebrities.Views
{
    public partial class BackAgentError : PhoneApplicationPage
    {
        #region Constructor
        public BackAgentError()
        {            
            InitializeComponent();
            Loaded += new RoutedEventHandler(BackAgentError_Loaded);
        }
        #endregion

        private void LoadAds()
        {
            try
            {
                PageHelper.LoadAdControl(LayoutRoot, adstackpl, 2);
            }
            catch (Exception ex)
            {
                Exceptions.SaveOrSendExceptions("Exception in LoadAds Method In BackAgentError.xaml.cs file file", ex);
                string excepmess = "Exception in LoadAds Method In BackAgentError.xaml.cs file.\n\n" + ex.Message + "\n\n StackTrace :- \n" + ex.StackTrace;
            }
        }
        protected override void OnNavigatedFrom(System.Windows.Navigation.NavigationEventArgs e)
        {
            FlurryWP8SDK.Api.EndTimedEvent("BackAgentError Page");
        }
        protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e)
        {
            FlurryWP8SDK.Api.LogPageView();
        }
        
        #region Page Load
        void BackAgentError_Loaded(object sender, RoutedEventArgs e)
        {
            LoadAds();
            FlurryWP8SDK.Api.LogEvent("BackAgentError Page", true);
            string backgroundAgentError = AppSettings.BackgroundAgenError;

            if (!string.IsNullOrEmpty(backgroundAgentError))
            {
                TbError.Text = backgroundAgentError;
                
            }
              
            else
            {
                NoError.Visibility = Visibility.Visible;
                NoError.Text = "No errors in background agent.";
            }
        }
        //private void LoadAds()
        //{
        //    try
        //    {
        //        PageHelper.LoadAdControl(LayoutRoot, adstackpl, 2);
        //    }
        //    catch (Exception ex)
        //    {
        //        //Exceptions.SaveOrSendExceptions("Exception in LoadAds Method In SongDetails file", ex);
        //        string excepmess = "Exception in LoadAds Method In SongDetails file.\n\n" + ex.Message + "\n\n StackTrace :- \n" + ex.StackTrace;
        //    }
        //}
        #endregion


        #region Events
        private void imgTitle_MouseEnter(object sender, System.Windows.Input.MouseButtonEventArgs e)
        {
            NavigationService.Navigate(NavigationHelper.MainPanoramaPage);
        }
        #endregion

        //private void btnmusic_click(object sender, EventArgs e)
        //{
        //    NavigationService.Navigate(new Uri("/Views/MusicSettings.xaml", UriKind.Relative));
        //}
    }
}